﻿using famails.App_Code.source.dto;
using famails.bus;
using famails.common;
using famails.dto;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace famails.BackEnd.Customer
{
    public partial class CustomerCare : System.Web.UI.Page
    {
        static log4net.ILog logs = log4net.LogManager.GetLogger("ErrorRollingLogFileAppender");
        static UserLoginDTO userLogin = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            userLogin = getUserLogin();
            if (!IsPostBack)
            {
                //txtStartDate.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm");
                txtStartDate_v.Value = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
                LoadData();
            }
        }

        private UserLoginDTO getUserLogin()
        {
            if (Session["us-login"] != null)
            {
                return (UserLoginDTO)Session["us-login"];
            }
            else Response.Redirect("~");
            return null;
        }
        private void LoadData()
        {
            try
            {

                CM_GroupBUS ulBus = new CM_GroupBUS();
                DataTable table = ulBus.GetAll2Order(getUserLogin().UserId);

                ddlGroup.DataTextField = "GroupName";
                ddlGroup.DataValueField = "GroupID";

                ddlGroup.DataSource = table;
                ddlGroup.DataBind();
                drlMailGroup_SelectedIndexChanged(null, EventArgs.Empty);

                //mail  config
                MailConfigBUS mailConfigBus = new MailConfigBUS();
                DataTable dtMailConfig = new DataTable();
                UserLoginDTO userLogin = getUserLogin();
                if (userLogin != null)
                {
                    if (userLogin.DepartmentId == 1)
                    {
                        dtMailConfig = mailConfigBus.GetAll();
                    }
                    else
                    {
                        dtMailConfig = mailConfigBus.GetByUserId(userLogin.UserId);
                    }
                }
                else
                {
                    Response.Redirect("login.aspx", false);
                }
                drlMailConfig.Items.Clear();
                drlMailConfig.DataSource = dtMailConfig.DefaultView;
                drlMailConfig.DataTextField = "Email";
                drlMailConfig.DataValueField = "Id";
                drlMailConfig.DataBind();

                DataTable tblSendContent = new DataTable();
                SendContentBUS scBUS = new SendContentBUS();
                if (userLogin.DepartmentId == 1)
                {
                    tblSendContent = scBUS.GetAll();
                }
                else
                {
                    tblSendContent = scBUS.GetAllSendContent(userLogin.UserId, Common.contentType.Broadcasting);
                }

                if (tblSendContent.Rows.Count > 0)
                {
                    DataRow rowE = tblSendContent.NewRow();
                    rowE["Id"] = 0;
                    rowE["Subject"] = "Chọn nội dung";
                    tblSendContent.Rows.InsertAt(rowE, 0);

                    drlContent.Items.Clear();
                    drlContent.DataSource = tblSendContent;
                    drlContent.DataTextField = "Subject";
                    drlContent.DataValueField = "Id";
                    drlContent.DataBind();
                }
            }
            catch (Exception ex)
            {

                pnSuccess.Visible = false;
                pnError.Visible = true;
                lblError.Text = " Đã xảy ra lỗi trong quá trình thực hiện. Vui lòng thử lại !<br/>" + ex.Message;
                logs.Error(userLogin.Username + "-CustomerCare-Group - LoadData", ex);
            }
        }

        protected void btnClose__ServerClick(object sender, EventArgs e)
        {
            Response.Redirect("CustomerCareList.aspx", false);
        }

        protected void btnPreview_ServerClick(object sender, EventArgs e)
        {

            string ContentMail = this.txtBody.Text;
            Session["Content"] = ContentMail;
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('../page/PreviewContent.aspx');", true);
            //ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", " $('#jqxwindow').jqxWindow('open');",true);
            //ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "$('#jqxwindow').jqxWindow('setContent', '<iframe src='../page/PreviewContent.aspx' width='100%' height='100%'></iframe>');",true);
        }

        protected void btnRefesh_ServerClick(object sender, EventArgs e)
        {

            drlMailConfig.SelectedIndex = 0;
            ddlGroup.SelectedIndex = 0;
            chkNow.Checked = true;
            chkSet.Checked = false;
            txtSubject.Text = "";
            drlContent.SelectedIndex = 0;
            drlSign.SelectedIndex = 0;
            txtBody.Text = "";
        }

        protected void btnSaveAndSend_ServerClick(object sender, EventArgs e)
        {
            try
            {
                if (CheckInput())
                {
                    string message = "";// checkLimitSendMail();
                    if (message != "")
                    {
                        pnError.Visible = true;
                        lblError.Text = message;
                    }
                    else
                    {
                        drlMailGroup_SelectedIndexChanged(sender, e);
                        DateTime? timeStart = DateTime.Now.AddMinutes(1);
                        if (txtStartDate_v.Value.ToString() != "" & this.chkNow.Checked == false)
                        {
                            timeStart = getTimeStart();
                        }

                        Insert(timeStart.Value, true);

                        logs.Info(userLogin.Username + " sent " + hdfCountCustomer.Value + " emails");
                    }
                }
            }
            catch (Exception ex)
            {
                pnError.Visible = true;
                lblError.Text = "Có lỗi trong quá trình đăng ký gửi email!";
                logs.Error(userLogin.Username + "-CustomerCare-Save-Send", ex);
            }
        }

        protected void btnSendNow__ServerClick(object sender, EventArgs e)
        {
            DateTime currentTime = DateTime.Now.AddMinutes(1);
            try
            {
                if (CheckInput())
                {
                    Insert(currentTime, false);
                }
            }
            catch (Exception ex)
            {
                pnError.Visible = true;
                lblError.Text = "Có lỗi trong quá trình đăng ký gửi email!";
                logs.Error(userLogin.Username + "-CustomerCare-btnSendNow_Click", ex);
            }
        }

        private bool CheckInput()
        {
            string message = "";
            if (txtSubject.Text + "" == "")
                message = "Vui lòng nhập tiêu đề";
            if (txtBody.Text + "" == "")
                message = "Vui lòng nhập nội dung";
            decimal emailCount = 0; decimal.TryParse(hdfCountCustomer.Value + "", out emailCount);
            if (emailCount <= 0)
                message = "Không có danh sách email để gửi!";

            DateTime? startSend = getTimeStart();
            if (startSend == null)
            {
                message = "Thời gian gửi không hợp lệ!!";
            }
            if (message.Length != 0)
            {
                pnError.Visible = true;
                lblError.Text = message;
                pnSuccess.Visible = false;
            }
            return message.Length == 0;
        }
        private void VisibleAll()
        {
            pnError.Visible = false;
            pnSuccess.Visible = false;
        }
        private void Insert(DateTime startDate, bool isSave)
        {
            CM_CustomerCareBUS srBUS = new CM_CustomerCareBUS();
            SendContentBUS scBUS = new SendContentBUS();
            SendContentDTO scDTO = new SendContentDTO();
            scDTO = getContentDTO();

            int contentID = 0;
            if (isSave)
            {
                contentID = scBUS.tblSendContent_insert(scDTO);
            }
            
            DateTime? startSend = getTimeStart();
            if (startSend == null)
            {
                pnError.Visible = true;
                lblError.Text = "Thời gian gửi không hợp lệ!!";
                return;
            }
            if (chkNow.Checked) startSend = DateTime.Now;
            CM_CustomerCareDTO srDto = new CM_CustomerCareDTO();// getCM_CustomerCare();
            srDto.SendContentId = contentID;
            srDto.StartDate = startSend.Value;
            srDto.Subject = txtSubject.Text;
            srDto.Body = txtBody.Text;
            srDto.createBy = userLogin.UserId;
            srDto.GroupID = Convert.ToInt32(ddlGroup.SelectedValue);
            srDto.MailConfigID = Convert.ToInt32(drlMailConfig.SelectedValue);
            srDto.CustomerCareID = Convert.ToInt32(srBUS.Insert(srDto));

            srBUS.AddSendMailByCustomerCareID(srDto.CustomerCareID, userLogin.UserId);
            pnError.Visible = false;
            pnSuccess.Visible = true;
            lblSuccess.Text = "Tạo email chăm sóc khách hàng thành công!";
            Response.Redirect("customercarelist.aspx",false);

        }

        private DateTime? getTimeStart()
        {
            try
            {
                if (chkNow.Checked)
                    return DateTime.Now;
                else
                {
                    string time = txtStartDate_v.Value;

                    string[] temp = time.Split(' ');
                    if (temp.Length != 2) return null;
                    else
                    {
                        string[] date = temp[0].Split('/');
                        temp = temp[1].Split(':');
                        DateTime value = new DateTime(Convert.ToInt32(date[2]), Convert.ToInt32(date[1]), Convert.ToInt32(date[0]), Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]), 0);
                        if (value < DateTime.Now) return null;
                        return value;
                    }
                }
            }
            catch
            {
                return null;
            }
        }
        private SendContentDTO getContentDTO()
        {
            SendContentDTO scDTO = new SendContentDTO();
            string err = ValidateNull();
            if (err == "")
            {
                scDTO.Body = txtBody.Text;
                scDTO.Subject = txtSubject.Text;
                scDTO.CreateDate = DateTime.Now;
                scDTO.userId = getUserLogin().UserId;
                scDTO.ContentType = 2;
            }
            else
            {
                pnSuccess.Visible = false;
                pnError.Visible = true;
                lblError.Text = err;
            }
            return scDTO;
        }
        private string ValidateNull()
        {
            string err = "";
            if (txtSubject.Text == "")
            {
                err = "Bạn chưa nhập tiêu đề Email";
            }
            else if (txtBody.Text == "")
            {
                err = "Bạn chưa nhập nội dung Email";
            }
            if (drlMailConfig.Text == "")
            {
                err = "Bạn chưa có email gửi";
            }
            return err;
        }
        protected void drlMailGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            int groupid = 0;
            int.TryParse(ddlGroup.SelectedValue, out groupid);
            if (groupid > -3)
            {
                bus.CM_CustomerBUS bus = new CM_CustomerBUS();
                decimal count = bus.CustomerCare_GetCustomerCountByGroupID(groupid, userLogin.UserId);
                hdfCountCustomer.Value = count+"";
                lblCountCustomer.Text = "Hiện có " + count.ToString("#,##0") + " khách hàng trong nhóm này !";
            }
            else lblCountCustomer.Text = "Không có khách hàng trong nhóm này!";
        }
        #region xu ly javascript
        [System.Web.Services.WebMethod]
        public static string getContentTemplate(string contentId)
        {
            SendContentBUS scBUS = new SendContentBUS();
            int id = int.Parse(contentId);
            DataTable tblContent = scBUS.GetByID(id);
            if (tblContent.Rows.Count > 0)
            {
                return tblContent.Rows[0]["Body"].ToString();
            }
            return null;
        }
        [System.Web.Services.WebMethod]
        public static string getJsonSpam(string contentId)
        {
            // Lay noi dung cho xu ly spam.
            SendContentBUS scBUS = new SendContentBUS();
            int id = int.Parse(contentId);
            string contentDetail = null;
            DataTable tblContent = scBUS.GetByID(id);
            if (tblContent.Rows.Count > 0)
            {
                contentDetail = tblContent.Rows[0]["Body"].ToString();
            }

            // Tien hanh check spam
            SpamRuleBUS spamBUS = new SpamRuleBUS();
            DataTable spam = spamBUS.GetAll();

            List<SpamRuleDTO> listSpam = new List<SpamRuleDTO>();
            for (int i = 0; i < spam.Rows.Count; i++)
            {
                SpamRuleDTO spamDto = new SpamRuleDTO();
                spamDto.Keyword = spam.Rows[i]["Keyword"].ToString();
                spamDto.SameWord = spam.Rows[i]["SameWord"].ToString();
                spamDto.Score = float.Parse(spam.Rows[i]["Score"].ToString());
                listSpam.Add(spamDto);
            }

            var json = new JavaScriptSerializer().Serialize(listSpam);
            return json;

        }

        [System.Web.Services.WebMethod]
        public static string getSign(string SignId)
        {
            try
            {
                SignatureBUS signBus = new SignatureBUS();
                int id = int.Parse(SignId);
                DataTable tblSign = signBus.GetById(id);
                if (tblSign.Rows.Count > 0)
                {
                    return tblSign.Rows[0]["SignatureContent"].ToString();
                }
                return null;
            }
            catch (Exception)
            {
                throw;
            }
        }
        [System.Web.Services.WebMethod]
        public static string getJsonList(string content)
        {
            SpamRuleBUS spamBUS = new SpamRuleBUS();
            DataTable spam = spamBUS.GetAll();

            List<SpamRuleDTO> listSpam = new List<SpamRuleDTO>();
            for (int i = 0; i < spam.Rows.Count; i++)
            {
                SpamRuleDTO spamDto = new SpamRuleDTO();
                spamDto.Keyword = spam.Rows[i]["Keyword"].ToString();
                spamDto.SameWord = spam.Rows[i]["SameWord"].ToString();
                spamDto.Score = float.Parse(spam.Rows[i]["Score"].ToString());
                listSpam.Add(spamDto);
            }

            var json = new JavaScriptSerializer().Serialize(listSpam);
            return json;
        }

        [System.Web.Services.WebMethod]
        public static string Spam(string title, string content)
        {
            try
            {
                SpamRuleBUS spamBUS = new SpamRuleBUS();
                DataTable spam = spamBUS.GetAll();
                float totalScoreTitle = 0;
                float totalScoreContent = 0;
                string ruleContent = "";
                float ItemScore = 0;
                string key = "";
                string titleData = title;
                string contentData = HttpUtility.UrlDecode(content);
                #region MyRegion
                #region Fisrt
                ruleContent = "<div class='toolTipBox' style='padding: 5px; margin-top: 10px; background-color: rgb(224, 236, 255);" +
                        "color: rgb(51, 51, 51); text-decoration: none; margin-bottom: 15px; font-family: Tahoma, Arial;" +
                        "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                        "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                        "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                        "-webkit-text-stroke-width: 0px;'>" +
                        "<img align='left' height='16' src='../resource/images/infoballon.gif' width='20' />Thống" +
                        "kê nội dung các quy tắc vi phạm của &#39;<b>Tiêu đề gửi</b>&#39; chi tiết như bên" +
                        " dưới:</div>" +
                        "<div class='Heading2' style='font-weight: bold; color: rgb(0, 0, 0); height: 16pt;" +
                        "background-color: rgb(237, 236, 236); padding: 4px 4px 4px 10px; background-image: url(../resource/images/table_bg.gif);" +
                        "font-family: Tahoma, Arial; font-size: 11px; font-style: normal; font-variant: normal;" +
                        "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                        "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                        "-webkit-text-stroke-width: 0px;'>" +
                        "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" +
                        "Quy tắc vi phạm</div>" +
                        "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" +
                        "padding: 3px 15px 3px 5px;'>" +
                        "Điểm</div>" +
                        "&nbsp;</div>" +
                        "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" +
                       " display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" +
                        "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                        "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                        "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                        "-webkit-text-stroke-width: 0px;'>";
                #endregion Fisrt
                foreach (DataRow RowItem in spam.Rows)
                {
                    key = " " + RowItem["Keyword"].ToString() + " ";
                    ItemScore = float.Parse(RowItem["Score"].ToString());
                    if (titleData.Contains(key) == true)
                    {
                        //Bắt đầu vòng lặp tính điểm tiêu đề
                        ruleContent += "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" +
                              "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" +
                              "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                              "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                              "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                              "-webkit-text-stroke-width: 0px;'>";
                        ruleContent += "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" + "Chứa từ vi phạm '" + key + "'" + "</div>" +
                         "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" + "padding: 3px 15px 3px 5px;'>" + ItemScore + "</div> </br>";
                        ruleContent += "</div>";
                        totalScoreTitle = totalScoreTitle + ItemScore;
                        // Kết thúc vòng lặp tính điểm tiêu đề
                    }
                }

                #region Medium
                ruleContent += "" +
                  "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" +
                   "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" +
                   "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                   "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                   "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                   "-webkit-text-stroke-width: 0px;'>" +
                   "<div class='spamRuleBroken_graph' style='border: 1px solid gray; height: 5px; background-color: rgb(238, 238, 238);'>" +
                   "<div class='spam_notspam' style='background-color: rgb(0, 255, 0); height: 5px; width: 165.296875px;'>" +
                   "<img height='5' src='../resource/images/1x1.gif' width='1' /></div>" +
                   "</div>" +
                   "<div style='line-height: 1; margin-bottom: 5px;'>" +
                   "<br />" +
                   "Nội dung được đánh giá cao nhất<span class ='Apple-converted-space'>&nbsp;</span><span" +
                   " style='font-size: 12px; font-weight: bold;'><b>" + totalScoreTitle.ToString() + "</b></span><span class='Apple-converted-space'>&nbsp;</span>trong" +
                   " ngưỡng cho phép là 5. Điều này có nghĩa email của bạn sẽ được gửi đến đích, nhưng" +
                   "điều này không được bảo đảm tuyệt đối nó chỉ có giá trị tham khảo.</div>" +
                "</div>" +
                "<div class='toolTipBox' style='padding: 5px; margin-top: 10px; background-color: rgb(224, 236, 255);" +
                "color: rgb(51, 51, 51); text-decoration: none; margin-bottom: 15px; font-family: Tahoma, Arial;" +
                "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                "-webkit-text-stroke-width: 0px;'>" +
                "<img align='left' height='16' src='../resource/images/infoballon.gif' width='20' />Thống" +
                " kê nội dung các quy tắc vi phạm của &#39;<b>Nội dung gửi</b>&#39; chi tiết như" +
                " bên dưới:" + "</div>" +
                 "<div class='Heading2' style='font-weight: bold; color: rgb(0, 0, 0); height: 16pt;" +
                 "background-color: rgb(237, 236, 236); padding: 4px 4px 4px 10px; background-image: url(../resource/images/table_bg.gif);" +
                 "font-family: Tahoma, Arial; font-size: 11px; font-style: normal; font-variant: normal;" +
                 "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                 "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                 "-webkit-text-stroke-width: 0px;'>" +
                 "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" +
                 "Quy tắc vi phạm</div>" +
                 "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" +
                 "padding: 3px 15px 3px 5px;'>" +
                 "Điểm</div>" +
                "&nbsp;</div>";

                #endregion
                //Đánh giá nội dung
                foreach (DataRow RowItem in spam.Rows)
                {
                    key = " " + RowItem["Keyword"].ToString() + " ";
                    ItemScore = float.Parse(RowItem["Score"].ToString());
                    if (contentData.Contains(key) == true)
                    {
                        //Bắt đầu vòng lặp tính điểm tiêu đề
                        ruleContent += "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" +
                                     "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" +
                                     "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                                     "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                                     "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                                     "-webkit-text-stroke-width: 0px;'>";
                        ruleContent += "<div class='spamRuleBroken_row_rulename' style='float: left; padding: 3px 0px 3px 5px;'>" + "Chứa từ vi phạm '" + key + "'" + "</div>" +
                         "<div class='spamRuleBroken_row_rulescore' style='float: right; width: 80px; text-align: right;" + "padding: 3px 15px 3px 5px;'>" + ItemScore + "</div></br>";
                        ruleContent += "</div>";
                        totalScoreContent = totalScoreContent + ItemScore;
                        // Kết thúc vòng lặp tính điểm tiêu đề
                    }
                }

                //Kết thúc đánh giá nội dung
                #region End
                ruleContent += "" +
                  "<div class='spam_info spamRuleBroken_row' style='padding: 4px 8px; background-color: rgb(249, 249, 249);" +
                  "display: block; clear: both; color: rgb(103, 103, 103); font-family: Tahoma, Arial;" +
                  "font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal;" +
                  "letter-spacing: normal; line-height: normal; orphans: auto; text-align: start;" +
                  "text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;" +
                  "-webkit-text-stroke-width: 0px;'>" +
                  "<div class='spamRuleBroken_graph' style='border: 1px solid gray; height: 5px; background-color: rgb(238, 238, 238);'>" +
                  "<div class='spam_notspam' style='background-color: rgb(0, 255, 0); height: 5px; width: 50%;'>" +
                  "<img height='5' src='../../resource/images/1x1.gif' width='1' /></div>" + "</div>" +
                   "<div style='line-height: 1; margin-bottom: 5px;'>" + "<br />" +
                   "Nội dung được đánh giá cao nhất<span class='Apple-converted-space'>&nbsp;</span><span" +
                   " style='font-size: 13px; font-weight: bold;'>" + totalScoreContent.ToString() + "</span><span class='Apple-converted-space'>&nbsp;</span>trong" +
                   " ngưỡng cho phép là 5. Điều này có nghĩa email của bạn sẽ được gửi đến đích, nhưng" +
                   "điều này không được bảo đảm tuyệt đối nó chỉ có giá trị tham khảo." +
                    "</div>" +
                "</div>";
                #endregion
                #endregion
                return ruleContent;
            }
            catch (Exception)
            {
                return null;
            }

        }
        #endregion
    }
}